package jdbc;

import java.sql.Connection;
import java.sql.Statement;

/**
 * 创建一张表article
 * 表结构
 * id 整数类型，自增，主键
 * title 字符串类型，长度200个字符   文章标题
 * content 字符串类型，长度1000个字符 文章内容
 */
public class Test {
    public static void main(String[] args) {
        //
        try(
            Connection conn = DBUtil.getConnection();
        ){
            // 创建statement对象
            Statement statement = conn.createStatement();

            // sql语句
            String sql = "CREATE TABLE article(" +
                    "id INT PRIMARY KEY AUTO_INCREMENT," +
                    "title VARCHAR(200)," +
                    "content VARCHAR(1000))";

            System.out.println(sql);
            statement.execute(sql);
            System.out.println("创建表成功");


        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
